import requests
from requests import utils

url_login = 'http://127.0.0.1:8787/dar/user/login'
header_login = {'Content-Type': 'application/x-www-formurlencoded;charset=UTF-8'}
data_login = {
    "user_name": "test01",
    "passwd": "admin123"
}

response = requests.post(url=url_login, data=data_login)
# 获取接口的cookie信息，一般是通过登录接口返回
print(response.cookies)
# 获取cookie，以字典类型返回
cookie = requests.utils.dict_from_cookiejar(response.cookies)
print(cookie)

# 后续接口怎么使用cookie信息来验证登录状态
url = 'http://127.0.0.1:8787/api/order/customer/orderPlan/getMaterial'
header = {'Content-Type': 'application/json;charset=UTF-8'}
res = requests.get(url=url, cookies=cookie)
print(res.text)
